<?php
class C_flowdetchecklist extends CI_Controller {
	function __construct(){
		parent::__construct();
		checkLogin();
		$this->load->model('m_flowdetchecklist');
	}
	function index(){
		$task = secure_post('task');
		switch($task){
			case 'LIST' :
				$this->_list();
				break;
			case 'INSERT' :
				$this->_insert();
				break;
			case 'UPDATE' :
				$this->_update();
				break;
			case 'DELETE' :
				$this->_delete();
				break;
			default :
				$this->load->view('v_flowdetchecklist');
		}
	}
	
	function _list(){
		$data['page'] = numeric_post("page");
		$data['rows'] = numeric_post("rows");
		$data['m_flowdet_id'] = nosql_post("m_flowdet_id");
		$data['m_checklist_id'] = nosql_post("m_checklist_id");
		echo $this->m_flowdetchecklist->_list($data);
	}
	
	function _insert(){
		$data = array(
			'm_flowdet_id' => $this->input->post('m_flowdet_id'), 
			'm_checklist_id' => $this->input->post('m_checklist_id'), 
			  
			'flowdetchecklist_active'=> 'y',
			'flowdetchecklist_insert_user'	=>$_SESSION[SESSION_USERNAMA],
			'flowdetchecklist_insert_date'=> date("Y-m-d h:i:s")
		);
		$this->m_flowdetchecklist->_insert($data);
		echo 1;
	}
	
	function _update(){
		$flowdetchecklist_id = $this->input->post('flowdetchecklist_id');
		$data = array(
			'm_flowdet_id' => $this->input->post('m_flowdet_id'), 
			'm_checklist_id' => $this->input->post('m_checklist_id'), 
			
			'flowdetchecklist_update_user'	=>$_SESSION[SESSION_USERNAMA],
			'flowdetchecklist_update_date'=> date("Y-m-d h:i:s")
		);
		$this->m_flowdetchecklist->_update($data,$flowdetchecklist_id);
		echo 1;
 	}
	
	function _delete(){
		$flowdetchecklist_id= $this->input->post('flowdetchecklist_id');
		$data = array(
			'flowdetchecklist_active' => 'n'
		);
		$this->m_flowdetchecklist->_delete($data,$flowdetchecklist_id);
		echo 1;
	}
}